<script>
    import Props from '../components/props.svelte'
    import Props2 from '../components/props2.svelte'
	let numbers = [1, 2, 3, 4];
    const pkg = {
		name: 'svelte',
		version: 3,
		speed: 'blazing',
		website: 'https://svelte.dev'
    };
    
	function addNumber() {
// 		numbers.push(numbers.length + 1);
		numbers[numbers.length] = numbers.length + 1;
	}

	$: sum = numbers.reduce((t, n) => t + n, 0);
</script>

<p>{numbers.join(' + ')} = {sum}</p>

<button on:click={addNumber}>
	Add a number
</button>

<!-- 父子组件传参 -->
<Props num={5} />
<!-- key 和子组件接受的对应的话可以直接通过对象解构传值 -->
<Props2  {...pkg} /> 